﻿namespace FSpec.Runner

open System
open System.Reflection 
open Gallio.Model.Helpers 
open Gallio.Common.Reflection 
open Gallio.Model
open FSpec.Runner.Model
    
///Manages test exploration
type SpecExplorer() =
    inherit TestExplorer() with 
        let culture = System.Globalization.CultureInfo.CurrentCulture 
        
        ///Test exploration    
        override this.ExploreImpl(reflectionPolicy, codeElement) = 
            let testCases = getTestCasesFrom codeElement
            let asm = ReflectionUtils.GetAssembly codeElement
            match asm with
            | null -> buildTestModelFrom this.TestModel.RootTest testCases
            | _ -> 
                let asmNode = new FSpecAssembly(asm)
                buildTestModelFrom asmNode testCases
                this.TestModel.RootTest.AddChild asmNode